<?php

namespace App\Admin\Controllers;

use App\Models\Lock;
use App\Models\LockRecord;
use App\Http\Controllers\Controller;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Callout;
// use Encore\Admin\Facades\Admin;
use Illuminate\Support\Facades\DB;
use Dcat\Admin\Form;
use App\Models\ProjectUser;
use App\Models\Project;
use Dcat\Admin\Admin;
use Dcat\Admin\Show;

class LockRecordController extends Controller
{
    public function index(Content $content, $lockId)
    {
        $lock = Lock::find($lockId);
        return $content
            ->header('开锁记录')
            ->description($lock['name'])
            ->body($this->grid($lockId));
    }

    protected function grid($lockId)
    {
        $m = LockRecord::where('lock_id', $lockId);
        return Grid::make($m, function (Grid $grid) {
            $grid->column('lock_name', '锁名称');
            $grid->column('operator_name', '操作人员');
            $grid->column('note', '备注');
            $grid->column('created_at', '开锁时间');
            $grid->disableActions();
            $grid->disableCreateButton();
        });
    }
}